﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BiliBiliCSharpStudy.old {
    /**
     * const : 常量
     * readonly : 只读属性
     * 
     */
    class ConstAndReadonlyDemo {
        public static void demo() {
            test1();
        }

        public static void test1() {
            Console.WriteLine(WASPEC.WebsiteURL);
        }
    }

    class WASPEC {
        public const string WebsiteURL = "http://www.waspec.org";

        // (1)
        // 错误 CS0133  指派给“WASPEC.Location”的表达式必须是常量
        //public const Building1 Location = new Building1() { Address = "Some Address" };

        // (2)
        // 错误 CS0133  指派给“WASPEC.Location”的表达式必须是常量
        //public const Building2 Location = new Building2("Some Address");

        // (3)
        // const -> static readonly
        public static readonly Building2 Location = new Building2("Some Address");
    }

    class Building1 {
        public string Address { get; set; }
    }

    class Building2 {
        public Building2(string address) {
            this.Address = address;
        }
        public string Address { get; set; }
    }
}
